-
Notifications
You must be signed in to change notification settings - Fork 1.3k
spotrem: add volume knob gesture #3847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Very cool! Works well when I tested it. Do you think it's worth mentioning that the clockwise/anticlockwise gesture detection is stopped after a brief period of no-interaction? Not for this PR, but if you wanted ideas on going further with this feature, it'd be cool to pull it out to a library and let other apps opt into the clockwise gesture, and during the clockwise gesture, display a circle on screen that follows the user's gesture. But obviously those are much bigger changes! |
Thanks :)
Yes! Will add that.
Yes - that's where I started with this. But I switched to this focused implementation first to dial in the UX (pun intended). |
Only the drag gesture functionality provided. I intend to add a companion module providing some relevant graphics, sharing the same options object.
@bobrippling this is maybe done now! Please comment any feedback you may have :) It now adds two new modules for dial functionality, one for touch interaction and one for graphics. This is used in |
if (isFill) g.fillCircle(x, y, rad); | ||
} | ||
if (this.isFirstDraw) { | ||
g.setColor(0,0,0).fillCircle(CENTER.x, CENTER.y, 25); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the radii for the drawing operations should not be hardcoded to 25, 23, 9 etc but depend on the DIAL_RECT
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe adding a additional displayRect
setting to the options object that if is not set defaults to what the dialRect
option is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think this is ok for now but we could have a follow-up PR which infers a radius from the rect? Or like you say, adds a setting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, lets leave it as is for now :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobrippling this is maybe done now! Please comment any feedback you may have :)
It now adds two new modules for dial functionality, one for touch interaction and one for graphics. This is used in
spotrem
to provide the volume knob.
Great, nice separation of functionality! I spotted a few things, let me know if I've been unclear or if you've any questions :)
|
||
```JS | ||
var Dial = require("Dial"); | ||
var dial = new Dial(cb, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use Dial
here as a constructor (no this
and it returns an object explicitly) so the new
(while it works) might confuse users. What about:
var dial = new Dial(cb, options) | |
var dial = dial(cb, options) |
(suggested lowercase dial
as it's no longer a class too, don't mind if you prefer it Titlecase though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - if that makes more sense I'm all for it.
I looked at the Layout module for inspiration when developing and taking a quick look now I fail to see how they differ in this regard. Out of interest, do they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I think I get what you mean now!
if (!isFill) g.drawCircle(x, y, rad); | ||
if (isFill) g.fillCircle(x, y, rad); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps:
if (!isFill) g.drawCircle(x, y, rad); | |
if (isFill) g.fillCircle(x, y, rad); | |
if (!isFill) g.drawCircle(x, y, rad); | |
else g.fillCircle(x, y, rad); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole drawCircle
should be removed I guess, when I think about it. I intended to use it more but now it's only used to make the small marks around the dial. (I had another design in mind at first where there would be small hollow circles around the dial, except for the one the indicator pointed to which would be filled.)
if (isFill) g.fillCircle(x, y, rad); | ||
} | ||
if (this.isFirstDraw) { | ||
g.setColor(0,0,0).fillCircle(CENTER.x, CENTER.y, 25); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think this is ok for now but we could have a follow-up PR which infers a radius from the rect? Or like you say, adds a setting
|
||
```JS | ||
var DialDisplay = require("Dial_Display"); | ||
var dialDisplay = new DialDisplay(options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same again (as the other comment), but here I think we'll want to change to make it more class-like, or alter how this
is used within the dialDisplay
function. At the moment it'll be writing to the global object.
For example, in the IDE:
> cb
=function (step) { ... }
>cb(1)
=undefined
>cb(1)
=undefined
// the dial renders successfully
// `this` variables are written to the global:
>isFirstDraw
=false
>value
=14
Happy to go through a few suggestions for it, if you like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to go through a few suggestions for it, if you like
Please do! Fun with a learning opportunity :) Feel free to commit to this PR.
Can be tried at: https://thyttan.github.io/BangleApps/?id=spotrem
Edit:
Adds two new modules for dial functionality, one for touch interaction and one for graphics. This is used in
spotrem
to provide the volume knob.